<template>
  <div class="address">
    <van-nav-bar title="确认订单" left-text="返回" left-arrow  @click-left="goBack"/>
    <router-link  class="address-top" tag="div" to="/cart/order/address"> 
      <div class="top-title">
        默认
      </div>
      <div class="top-content">
        <p>{{ address.address }}</p>
        <div class="content-name">
          <p>{{ address.name }}</p>
          <p>{{ address.mobile }}</p> 
        </div>
      </div> 
      <img src="@/assets/go.png" alt="">
    </router-link>
    <div class="goods" v-for="item in goodsList.goodsList" :key="item.id">
        <img :src="item.list_pic_url" alt="">
        
        <div class="goods-content">
          <p>{{ item.goods_name }}</p>
          <div class="content-name">
            <p>¥{{ item.retail_price }}</p>
            <p class="number">X{{ item.number }}</p>
          </div>
        </div>
    </div>
    <div class="detail">
        <div class="detail-item">
          <p>商品合计</p>
          <p>{{ goodsList.allPrise }}</p>
        </div>
        <div class="detail-item">
          <p>运费</p>
          <p>免运费</p>
        </div>
        <div class="detail-item">
          <p>优惠券</p>
          <p>暂无</p>
        </div>
    </div>
    <div class="bottom">
      <p>实付:<span>¥{{ goodsList.allPrise }}</span></p>
      <div>
        支付
      </div>
    </div>
  </div>
</template>

<script>
import {detailAction } from "@/api/cart/order/index";
export default {
  data() {
    return {
        address:{},
        goodsList:[]
    };
  },

  created() {
    detailAction({
      openId: localStorage.getItem("openId"),
      addressId: "",
    }).then((res) => {
      console.log(res);
      var address = JSON.parse(localStorage.getItem("addressInfo"))
      if(address){
        res.address = address
      }
      this.address = res.address
      this.goodsList = res 
    });
  },

  mounted() {},

  methods: {
    goBack(){
      this.$router.go(-1)
    }
  },
};
</script>

<style scoped lang="scss">
@import "../scss/order/index.scss";
* {
  margin: 0px;
  padding: 0px;
}
</style>